package com.cw.jeeyt.dao.impl.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.cw.jeeyt.common.Order;
import com.cw.jeeyt.dao.intf.api.ApiFacadeProjectInfoDao;
import com.cw.jeeyt.dao.mapper.api.ApiFacadeProjectInfoMapper;
import com.cw.jeeyt.dao.model.api.ApiFacadeProjectInfoDo;
import com.cw.lang.common.utils.PageUtil;
import com.cw.lang.common.pagehelper.PageHelper;
import com.cw.lang.mybatis.dto.PageInfo;

/**
 * api接口文档所在项目 dao数据库操作接口
 *
 * @author chenw
 * @version 1.0.0
 */
@Repository
public class ApiFacadeProjectInfoDaoImpl implements ApiFacadeProjectInfoDao {
    @Autowired
    private ApiFacadeProjectInfoMapper apiFacadeProjectInfoMapper;

    /**
     * 新增api接口文档所在项目
     *
     * @param apiFacadeProjectInfo
     * @return 整数
     */
    public Integer insert(ApiFacadeProjectInfoDo apiFacadeProjectInfo) {
        return apiFacadeProjectInfoMapper.insert(apiFacadeProjectInfo);
    }

    /**
     * 新增api接口文档所在项目不为空的字段
     *
     * @param apiFacadeProjectInfo
     * @return 整数
     */
    public Integer insertSelective(ApiFacadeProjectInfoDo apiFacadeProjectInfo) {
        return apiFacadeProjectInfoMapper.insertSelective(apiFacadeProjectInfo);
    }

    /**
     * 删除api接口文档所在项目
     *
     * @param apiFacadeProjectInfo
     */
    public void delete(ApiFacadeProjectInfoDo apiFacadeProjectInfo) {
        apiFacadeProjectInfoMapper.delete(apiFacadeProjectInfo);
    }

    /**
     * 修改api接口文档所在项目不为null的字段
     *
     * @param apiFacadeProjectInfo
     */
    public void updateSelective(ApiFacadeProjectInfoDo apiFacadeProjectInfo) {
        apiFacadeProjectInfoMapper.updateSelective(apiFacadeProjectInfo);
    }

    /**
     * 修改api接口文档所在项目
     *
     * @param apiFacadeProjectInfo
     */
    public void update(ApiFacadeProjectInfoDo apiFacadeProjectInfo) {
        apiFacadeProjectInfoMapper.update(apiFacadeProjectInfo);
    }

    /**
     * 根据主键查询api接口文档所在项目
     *
     * @return api接口文档所在项目
     */
    public ApiFacadeProjectInfoDo getById(Long id) {
        return apiFacadeProjectInfoMapper.getById(id);
    }

    /**
     * 查询所有api接口文档所在项目
     *
     * @return api接口文档所在项目集合
     */
    public List<ApiFacadeProjectInfoDo> queryApiFacadeProjectInfoList() {
        return apiFacadeProjectInfoMapper.queryApiFacadeProjectInfoList();
    }

    /**
     * 分页查询api接口文档所在项目
     *
     * @param apiFacadeProjectInfo 查询条件
     * @param startRow 开始条数
     * @param pageSize 每页长度
     * @return api接口文档所在项目集合
     */
    public PageInfo<ApiFacadeProjectInfoDo> queryByPage(ApiFacadeProjectInfoDo apiFacadeProjectInfo, Integer startRow,
        Integer pageSize, Order order) {
        PageHelper.startPage(PageUtil.calPageNum(startRow, pageSize), pageSize);
        return new PageInfo<>(apiFacadeProjectInfoMapper.queryByPage(apiFacadeProjectInfo, order));
    }

    /**
     * 批量新增接口项目信息
     *
     * @param projectInfoList
     * @return
     * @throws Exception
     */
    public Integer insertBat(List<ApiFacadeProjectInfoDo> projectInfoList) {
        return apiFacadeProjectInfoMapper.insertBat(projectInfoList);
    }

    /**
     * 根据项目编码查询项目信息
     *
     * @param projectCodes
     * @return
     * @throws Exception
     */
    public List<ApiFacadeProjectInfoDo> queryListByProjectCodes(List<String> projectCodes) {
        return apiFacadeProjectInfoMapper.queryListByProjectCodes(projectCodes);
    }
}
